home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12662 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: abacus.abasoft.co.uk!not-for-mail
  2. From: dmb@abacus.abasoft.co.uk (David Byrne)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: What is wrong with this code?
  5. Date: 20 Mar 1996 13:12:02 -0000
  6. Organization: Abacus Software Ltd.
  7. Message-ID: <4ip072$b9f@abacus.abasoft.co.uk>
  8. References: <4il0pn$fp@news1.io.org>
  9. NNTP-Posting-Host: abacus.abasoft.co.uk
  10. X-NNTP-Posting-Host: abacus.demon.co.uk
  11.  
  12. vector::~vector (void) {
  13.   if (data) delete data;
  14.   if (name) delete name;
  15. }
  16.  
  17. should be
  18.  
  19. vector::~vector (void) {
  20.   if (data) delete[] data;
  21.   if (name) delete[] name;
  22. }
  23.  
  24. However, the program works using g++ 2.7.0:
  25.  
  26. $ g++ test.cpp
  27. $ a.out
  28. Vector 'first' is of dimension 4 and it's parameters are:
  29.  
  30. first[1] = 1
  31. first[2] = 2
  32. first[3] = 3
  33. first[4] = 4
  34. Vector 'second' is of dimension 2 and it's parameters are:
  35.  
  36. second[1] = 1.1
  37. second[2] = 1.2
  38. Vector 'unnamed' is of dimension 4 and it's parameters are:
  39.  
  40. unnamed[1] = 3
  41. unnamed[2] = 6
  42. unnamed[3] = 9
  43. unnamed[4] = 12
  44.  
  45. $
  46. -- 
  47. David Byrne, Abacus Software, London, UK              Tel: +44 (0)171 603 9877
  48. Email: dmb@abacus.demon.co.uk                         Fax: +44 (0)171 603 6844
  49. Here's a koan: If you have ice-cream I will give you some. If you have none,
  50.                I will take it away from you. (it's an ice-cream koan).
  51.